#!/usr/bin/env python
# @Software: PyCharm
# @Time : 2022/9/2 19:22
# @Author : v_nahuachen
# @Version：V 0.1
# @File : app_test.py
# @desc :
from cases.base.base_case import BaseCase
from cases.pages import home_page
from cases.pages import base_page


class AppTest(BaseCase):

    def setUp(self) -> None:
        super().setUp()
        # 页面跳转
        self.HomePage.interface_page("app")

    def __init__(self, methodName='runTest'):
        """
        初始化App实例类
        """
        super(AppTest, self).__init__(methodName)
        self.HomePage = home_page.HomePage(self)
        self.BasePage = base_page.BasePage(self)

    def test_hook_wx_method(self):
        """
        hook 小程序方法 getSystemInfo
        :return:
        """
        is_called, callback_args = self.BasePage.hook_wx_method("getSystemInfo", "#testhook1")
        self.assertTrue(is_called, "callback called")
        self.assertDictContainsSubset(
            {"errMsg": "getSystemInfo:ok"}, callback_args, "getSystemInfo"
        )

